<template>
    <div class="app-container">
        <el-table v-loading="loading" :data="list" border>
            <el-table-column label="演练计划标题" align="center" prop="planTitle" />
            <el-table-column label="演练日期" align="center" prop="planDate" width="180"> </el-table-column>
            <el-table-column label="演练地点" align="center" prop="planLocation" />
            <el-table-column label="创建单位" align="center" prop="deptName" />
            <el-table-column label="创建人员" align="center" prop="createUserName"> </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" @click="handleDetail(scope.row)">详情</el-button>
                    <el-button size="mini" type="text" @click="handleReport(scope.row)" v-if="scope.row.reportStatus == 0">演练总结</el-button>
                    <el-button size="mini" type="text" @click="handleReportDetail(scope.row)" v-if="scope.row.reportStatus == 1">查看总结报告</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
</template>

<script>
import * as DrillApi from "@/api/drill/drill.js";
import * as Auth from "@/utils/auth";

export default {
    name: "DrillPlan",
    dicts: ["eventlevelcode_dict", "drillcate_dict", "drilltype_dict"],
    components: {},
    data() {
        return {
            // 遮罩层
            loading: false,
            // 总条数
            total: 10,
            // 应急演练计划表格数据
            list: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                createUser: 0,
            },
            userId: 0,
        };
    },
    created() {
        // 获取用户ID
        this.userId = Auth.getUserId();
        this.getList();
    },
    methods: {
        getList() {
            DrillApi.getEndDrillPlanList(this.queryParams).then(res => {
                this.list = res.rows;
                this.total = res.total;
            });
        },

        handleDetail(data) {
            this.$tab.openPage("演练计划详情", "/drill/drillDetail", { planId: data.planId });
        },
        handleReport(data) {
            this.$tab.openPage("演练总结", "/drill/report/form", { planId: data.planId });
        },
        handleReportDetail(data) {
            this.$tab.openPage("演练总结报告", "/drill/report/detail", { planId: data.planId });
        },
    },
};
</script>
<style lang="scss" scoped></style>
